package gateway.mgt

class BootStrap {

    def init = { servletContext ->
        def groupDemo = new ApiGroup(name: "GATEWAY-CORE")
        if (!groupDemo.save(flush: true))
            println groupDemo.errors

        [
                [
                        apiGroup: groupDemo, name: "demo1", description: "demo api 1",
                        request : [path: "/Service-Set-1/sampleApi1"], backend: [host: "lb://Service-Set-1", path: "/sampleApi1"]
                ],
                [
                        apiGroup: groupDemo, name: "demo2", description: "demo api 2",
                        request : [path: "/Service-Set-2/sampleApi2"], backend: [host: "lb://Service-Set-2", path: "/sampleApi2"]
                ]
        ].each { apiParams ->
            def apiDemo = new ApiDefinition(apiParams)
            if (!apiDemo.save())
                println apiDemo.errors
        }
    }
    def destroy = {
    }
}
